package com.frxuexi.park2212.hourse

import androidx.lifecycle.MutableLiveData
import com.frxuexi.lib_base.base.BaseViewModel
import com.frxuexi.lib_base.entity.HourseBean
import com.frxuexi.lib_base.entity.HourseBeanItem
import com.frxuexi.lib_base.net.ApiService
import dagger.hilt.android.lifecycle.HiltViewModel
import javax.inject.Inject

@HiltViewModel
class HourseViewModel @Inject constructor(val apiService: ApiService):BaseViewModel() {
    var getHourses = MutableLiveData<HourseBean>()

    var rent = MutableLiveData<HourseBeanItem>()

    fun getHourses(){
        httpRequest({apiService.getHourses()},getHourses::postValue)
    }

    fun getHourseByRid(rid:Int){
        httpRequest({apiService.getHourseByRid(rid)},getHourses::postValue)
    }

    fun rent(id:Int,rentDate:String){
        httpRequest({apiService.rent(id,rentDate)},rent::postValue)
    }

    fun unrent(id:Int){
        httpRequest({apiService.unrent(id)},rent::postValue)
    }
}